﻿using NetMicro.EventBus;
using NetMicro.EventBus.Extensions;
using NetMicro.EventBus.MySql;
using NetMicro.EventBus.RabbitMQ;
using NetMicro.Host;
using Sample.Eventbus;

namespace Sample
{
    public class Startup : StartupProvider
    {
        public Startup(IHostEnvironment env, IConfiguration cfg) : base(env, cfg)
        {
        }

        public override void ConfigureServices(IServiceCollection services)
        {
            base.ConfigureServices(services);
            services.AddEventBus(m =>
            {
                m.UseMessageRetry<TestEventHandler, TestEvent>(3, TimeSpan.FromSeconds(30));
            }).AddMySql(m =>
            {
                m.DeadLetterMessageExpireTime = TimeSpan.FromMinutes(1);
                m.ConnectionString = "server=cc68.online;port=3306;database=testmq;user id=root;password=123456;pooling=true;sslmode=none;Charset=utf8;allowPublicKeyRetrieval=true;";
            })
            .AddRabbitMQ(r =>
            {
                r.Host = "cc68.online";
                r.UserName = "guest";
                r.Password = "guest";
            });
        }
    }
}
